package persistenty;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

import model.container.CursistenException;
import model.container.CursussenException;
import model.container.InschrijvingenException;
import model.container.LectorenException;

public abstract class ContainerTekstPersisteerbaar {
	ContainerTekstPersisteerbaar container;
	protected String objectAlsTekst = null;
	protected Object objectVanTekst = null;
	protected ArrayList<String> persistentyFiles = new ArrayList<String>();
	protected String inputFile;

	public final void uitlezen() throws Exception {
		for (String file : persistentyFiles) {
			inputFile = file;
			openReader(file);
		}
	}

	public static void delete(String file) throws IOException {
		File oldFile = new File(file);
		oldFile.delete();
	}

	final void openReader(String file) throws Exception {
		try {
			BufferedReader reader = new BufferedReader(new FileReader(file));
			while ((objectAlsTekst = reader.readLine()) != null) {
				createObject();
			}
			reader.close();
		} catch (FileNotFoundException e) {

			e.printStackTrace();
		} catch (IOException e) {

			e.printStackTrace();
		}
	}

	public void createObject() throws CloneNotSupportedException, CursistenException, CursussenException,
			InschrijvingenException, LectorenException, Exception {
	}

	public abstract void schrijven() throws IOException;

}
